package com.panshi.interceptor;


import com.jfinal.aop.Interceptor;
import com.jfinal.aop.Invocation;
import com.jfinal.core.Controller;
import com.panshi.tools.PanshiAppMd5Sign;
import com.panshi.tools.ResponseData;

public class SMSInterceptor implements Interceptor {


    public void intercept(Invocation invocation) {

        Controller controller = invocation.getController();

        String sig = controller.getPara("sig", "0"); //获取签名
        String mobile = controller.getPara("mobile", "0");//获取短信手机号

        String md5keysCheck = PanshiAppMd5Sign.getMd5keysCheck(mobile);


        if (md5keysCheck.equals(sig))
            invocation.invoke(); //验证通过并放行
        else

        {
            controller.renderJson(ResponseData.unauthorized());
            return;
        }
    }
}
